<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0/no">
    <meta content="telephone=no,email=no" name="format-detection"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>智能社--http://www.zhinengshe.com</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        div{
            width: 250px;
            height: 250px;
            background: red;
            margin: 50px auto;
        }
    </style>
    <script>
        function a2d(n){
            return n*180/Math.PI;
        }
        document.addEventListener('DOMContentLoaded',function(){
            var oDiv=document.getElementsByTagName('div')[0];
            var s=0;

            oDiv.addEventListener('touchstart',function(ev){
                var oldS=s;
                function getS(ev){
                    var x1=ev.targetTouches[0].pageX;
                    var y1=ev.targetTouches[0].pageY;

                    var x2=ev.targetTouches[1].pageX;
                    var y2=ev.targetTouches[1].pageY;

                    var x=(x2+x1)/2;
                    var y=(y2+y1)/2;

                    return {x:x,y:y};
                }

                if(ev.targetTouches.length==2){
                    var downJson=getS(ev);
                }

                function fnMove(ev){
                    if(ev.targetTouches.length==2){
                        var moveJson=getS(ev);

                        oDiv.style.WebkitTransform='translate('+(moveJson.x-downJson.x)+'px,'+(moveJson.y-downJson.y)+'px)';
                    }
                }

                function fnEnd(ev){
                    document.removeEventListener('touchmove',fnMove,false);
                    document.removeEventListener('touchend',fnEnd,false);
                }

                document.addEventListener('touchmove',fnMove,false);
                document.addEventListener('touchend',fnEnd,false);
                ev.preventDefault();
            },false);
        },false);
    </script>
</head>
<body>
    <div></div>
</body>
</html>
















